/**
 * 
 */
package de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.tests;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word;
import de.uni_leipzig.informatik.asv.util.Encoder;
/**
 * @author christoph
 *
 */
public class TestWord
{
	/**
	 * 
	 */
	private Encoder e;
	/**
	 * 
	 */
	private Word w1;
	/**
	 * 
	 */
	private Word w2;
	/**
	 * 
	 */
	private Word w3;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		e = new Encoder();
		w1 = new Word(e.ensure("Hans"), e.ensure("Deutsch"), 14.3);
		w2 = new Word(e.ensure("Hans"), e.ensure("English"), 5.9);
		w3 = new Word(e.ensure("geht"), e.ensure("Deutsch"), 13.0);
		w1.addConnection(w2, e.ensure("Translation"), 2.4);
		w3.addConnection(w1, e.ensure("Following"), 5.3);
		w1.addFeature(e.ensure("small"), 4.3);
		w1.addFeature(e.ensure("round"), 2.1);
		w2.addFeature(e.ensure("counter"), 8.1);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getIdentity()}.
	 */
	@Test
	public void testGetIdentity()
	{assertEquals(w1.getIdentity(),e.ensure("Hans"));}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getLanguage()}.
	 */
	@Test
	public void testGetLanguage()
	{assertEquals(w1.getLanguage(),e.ensure("Deutsch"));}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getAmount()}.
	 */
	@Test
	public void testGetAmount()
	{assertEquals(w1.getAmount(), 14.3, 0.000001);}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getNumberOfConnections()}.
	 */
	@Test
	public void testGetNumberOfConnections()
	{
		assertEquals(w1.getNumberOfConnections(), 1);
		assertEquals(w2.getNumberOfConnections(), 0);
		assertEquals(w3.getNumberOfConnections(), 1);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getConnectionLabel(int)}.
	 */
	@Test
	public void testGetConnectionLabel()
	{assertEquals(w1.getConnectionLabel(0),e.ensure("Translation"));}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getConnectionWeight(int)}.
	 */
	@Test
	public void testGetConnectionWeight()
	{assertEquals(w1.getConnectionWeight(0), 2.4, 0.0000001);}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getConnectedWord(int)}.
	 */
	@Test
	public void testGetConnectedWord()
	{
		assertEquals(w1.getConnectedWord(0),w2);
		assertEquals(w3.getConnectedWord(0),w1);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getFeatureValue(int)}.
	 */
	@Test
	public void testGetFeatureValue()
	{
		assertEquals(w1.getFeatureValue(0),4.3,0.000001);
		assertEquals(w1.getFeatureValue(1),2.1,0.000001);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getFeatureName(int)}.
	 */
	@Test
	public void testGetFeatureName()
	{assertEquals(w1.getFeatureName(0),e.ensure("small"));}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getNumberOfFeatures()}.
	 */
	@Test
	public void testGetNumberOfFeatures()
	{
		assertEquals(w1.getNumberOfFeatures(),2);
		assertEquals(w2.getNumberOfFeatures(),1);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getReverseConnectionLabel(int)}.
	 */
	@Test
	public void testGetReverseConnectionLabel()
	{assertEquals(w1.getReverseConnectionLabel(0),e.ensure("Following"));}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getReverseConnectionWeight(int)}.
	 */
	@Test
	public void testGetReverseConnectionWeight()
	{assertEquals(w1.getReverseConnectionWeight(0),5.3,0.000001);}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getReverseConnectedWord(int)}.
	 */
	@Test
	public void testGetReverseConnectedWord()
	{assertEquals(w1.getReverseConnectedWord(0),w3);}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.data.Word#getNumberOfReverseConnections()}.
	 */
	@Test
	public void testGetNumberOfReverseConnections()
	{
		assertEquals(w1.getNumberOfReverseConnections(),1);
		assertEquals(w2.getNumberOfReverseConnections(),1);
		assertEquals(w3.getNumberOfReverseConnections(),0);
	}
}